package com.yw.start.main;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URLClassLoader;

public class StartMain {
	private static String path;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("server is starting......");
		loadPath();// 加载工作路径
		StartMain start = new StartMain();
		try {
			start.loadJar();
			SystemLoader.loadConfig(path);
			SystemLoader.loadModel();
			System.out.println("server is start");
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static void loadPath() {
		String temp = System.getProperty("user.dir");
		path = temp;
		System.out.println("work path is " + path);
	}

	private void loadJar() throws MalformedURLException, Exception {
		String jarPath = path + "/lib";
		File libdir = new File(jarPath);
		if (libdir == null || !libdir.isDirectory()) {
			return;
		}
		System.out.println("load jar...");
		JarLoader jarLoader = new JarLoader(
				(URLClassLoader) ClassLoader.getSystemClassLoader());
		jarLoader.loadjar(jarLoader,path + "/lib");		
	}

}
